﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminMaster.Master" Inherits="System.Web.Mvc.ViewPage<VietThuongLMS.Areas.Admin.Models.AccountModel>" %>



<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript" src="<%: Url.Content("~/Scripts/MicrosoftAjax.js") %>"></script>
    <script type="text/javascript" src="<%: Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>"></script>
    
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <legend>
        <h2>
            Thêm tài khoản</h2>
    </legend>
    <input hidden id="checkpoint" type="checkbox" disabled/>
    <% Html.EnableClientValidation();
       using (Html.BeginForm("Create", "Account", new { area = "Admin" }, FormMethod.Post, new { @class = "form-horizontal", @id = "formNew", @name = "formNew", enctype = "multipart/form-data" }))
       {
    %>
    <input type="hidden" id="hCheckedBook" name="hCheckedBook" />
    <%: Html.ValidationSummary(true) %>
    <div class="control-group">
        <label class="control-label" for="strFrom">
            Tên tài khoản:</label>
        <div class="controls">
            <%: Html.TextBoxFor(t => t.UserName, new { @class = "h30", placeholder = "User name...", onblur = "check_invalid();" })%>
            <%: Html.ValidationMessageFor(m => m.UserName) %>
            
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="strFrom">
            Họ tên :</label>
        <div class="controls">
            <%: Html.TextBoxFor(t => t.FullName, new { @class = "h30", placeholder = "Full name..." })%>
            <%: Html.ValidationMessageFor(m => m.FullName) %>
            
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="strFrom">
            Địa chỉ :</label>
        <div class="controls">
            <%: Html.TextBoxFor(t => t.Address, new { @class = "h30", placeholder = "Address..." })%>
            <%: Html.ValidationMessageFor(m => m.Address)%>
            
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="strFrom">
            Điện thoại :</label>
        <div class="controls">
            <%: Html.TextBoxFor(t => t.Phone, new { @class = "h30", placeholder = "Phone..." })%>
            <%: Html.ValidationMessageFor(m => m.Phone)%>
            
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="strFrom">
            Email :</label>
        <div class="controls">
            <%: Html.TextBoxFor(t => t.Email, new { @class = "h30", placeholder = "Email..." })%>
            <%: Html.ValidationMessageFor(m => m.Email)%>
            
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="AdminContent">
            Quyền:</label>
        <div class="controls">
            <%= Html.DropDownList("Role", (SelectList)ViewData["CBRole"])%>     
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <button id="btnCreate" name="btnCreate" type="submit" class="btn btn-primary">Tạo tài khoản</button>
        </div>
    </div>
    <% } %>
    

    <script type="text/javascript" src="<%: Url.Content("~/Plugins/datepicker/js/bootstrap-datepicker.js")%>"></script>
    <script type="text/javascript">
        function check_invalid() {
            var username = $('#UserName').val();
            $.ajax({
                url: '<%: Url.Action("CheckValid")%>',
                data: { 'username': username },
                type: "post",
                cache: false,
                success: function (msg) {
                    if (msg == "False") {
                        $('#checkpoint').prop('checked', false);
                        alert("Username is invalid");
                    }
                    else if (msg == "True")
                        $('#checkpoint').prop('checked', true);
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert("fail");
                }
            });
        }
    </script>
</asp:Content>